/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.classes;

import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;

/**
 *
 * @author marc
 */
public class CommonUtils {
    public static String URL_DATABASE="192.168.162.130";
    public static int PORT_DATABASE=9160;
    public static String BBBCONFERENCE_KEYSPACE="BBBConference";
    
    public static java.util.UUID getTimeUUID()
    {
        return java.util.UUID.fromString(new com.eaio.uuid.UUID().toString());
    }
    public static byte[] asByteArray(java.util.UUID uuid)
     {
        long msb = uuid.getMostSignificantBits();
        long lsb = uuid.getLeastSignificantBits();
        byte[] buffer = new byte[16];

        for (int i = 0; i < 8; i++) {
                buffer[i] = (byte) (msb >>> 8 * (7 - i));
        }
        for (int i = 8; i < 16; i++) {
                buffer[i] = (byte) (lsb >>> 8 * (7 - i));
        }

        return buffer;

    }

    public static Document parseXmlFile(String urlxml){
	Document dom=null;
        //get the factory
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

        try {

                //Using factory get an instance of document builder
                DocumentBuilder db = dbf.newDocumentBuilder();

                //parse using builder to get DOM representation of the XML file
                dom = db.parse(urlxml);


        }catch(ParserConfigurationException pce) {
                pce.printStackTrace();
        }catch(SAXException se) {
                se.printStackTrace();
        }catch(IOException ioe) {
                ioe.printStackTrace();
        }
        return dom;
    }
}
